import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.*;

/**
 * Created by 14229 on 2020/2/21.
 */
public class Test08 {
    public static void main(String[] args) throws IOException {

        List<Student> list = getStuList();
        for (Student student : list) {
            System.out.println(student.getId() + "  " + student.getScore());
        }
    }
        public static List<Student> getStuList() throws IOException {
            List<Student> list = new ArrayList<>();
            List<String> lines = FileUtils.readLines(new File("student.txt"), "UTF-8");
            for (String line : lines) {
                String[] split = line.split(",");
                list.add(new Student(split[0],split[1],Integer.parseInt(split[2])));
            }
            Set<Student> set = new HashSet<>(list);
            list.clear();
            list.addAll(set);
            Collections.sort(list, new Comparator<Student>() {
                @Override
                public int compare(Student o1, Student o2) {
                    if (o1.getScore()==o2.getScore()){
                        int s1 = Integer.parseInt(o1.getId().replace("s", ""));
                        int s2 = Integer.parseInt(o2.getId().replace("s", ""));
                        return s1-s2;
                    }
                    return o1.getScore()-o2.getScore();
                }
            });
            //代码填充
return list;
        }
    }
